package com.ctsi.framework.rest.api.config;

import com.ctsi.framework.common.exception.GlobalExceptionHandler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableAsync;

/**
 * @author zhangjw
 * @Date: 2018/9/4 15:31
 * @Description: Rest API servlet manager with version
 */
@Configuration
@EnableAsync
@ComponentScan(basePackages = {"com.ctsi.**.api.impl.rest","com.ctsi.**.app.rest","com.ctsi.**.app.controller","com.ctsi.**.controller"},
basePackageClasses = {GlobalExceptionHandler.class},lazyInit = true)
public class RestApiDispatcherServletConfiguration {

    private static final Logger logger = LoggerFactory.getLogger(RestApiDispatcherServletConfiguration.class);



//    @Bean
//    public LocaleChangeInterceptor localeChangeInterceptor() {
//        logger.debug("Configuring localeChangeInterceptor");
//        LocaleChangeInterceptor localeChangeInterceptor = new LocaleChangeInterceptor();
//        localeChangeInterceptor.setParamName("language");
//        return localeChangeInterceptor;
//    }
//
//    @Bean
//    public WebMvcRegistrations webMvcRegistrations(){
//        return new WebMvcRegistrations() {
//
//            private RequestMappingHandlerMapping requestMappingHandlerMapping;
//
//            private void init(){
//                if(requestMappingHandlerMapping == null) {
//                    logger.info("Creating version control support requestMappingHandlerMapping");
//                    RequestMappingHandlerMapping requestMappingHandlerMapping = new RestApiRequestMappingHandlerMapping();
//                    requestMappingHandlerMapping.setUseSuffixPatternMatch(false);
//                    requestMappingHandlerMapping.setRemoveSemicolonContent(false);
//                    Object[] interceptors = { localeChangeInterceptor() };
//                    requestMappingHandlerMapping.setInterceptors(interceptors);
//                    this.requestMappingHandlerMapping = requestMappingHandlerMapping;
//                }
//            }
//
//            @Override
//            public RequestMappingHandlerMapping getRequestMappingHandlerMapping() {
//                init();
//                return this.requestMappingHandlerMapping;
//            }
//        };
//    }


}
